from Base import Base
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
class Page(Base):
    #点击登录
    login_py = (By.XPATH,'//*[@id="com_userbar"]/ul/li[4]/div/a')
    def login(self):
        self.driver.click(self.login_py)
    #点击手机登录
    sjdl_py = (By.ID,'TANGRAM__PSP_4__footerULoginBtn')
    def sjdl(self):
        self.driver.click(self.sjdl_py)
    #输入账号
    srzh_py = (By.NAME,'userName')
    def srzh(self):
        self.driver.send_keys(self.srzh_py)
    #输入密码
    # srmm_py = (By.CLASS_NAME,'密码')
    srmm_py = (By.ID,'TANGRAM__PSP_4__password'and By.NAME,'password')
    def srmm(self):
        self.driver.send_keys(self.srmm_py)
    #点击登录
    djdl_py = (By.XPATH,'/html/body/div[7]/div[2]/div[1]/form/p[11]/input')
    def djdl(self):
        self.driver.click(self.djdl_py)
    #断言1 到贴吧首页
    dy_py = (By.XPATH,'//*[@id="head"]/div/div[2]/div/div[1]/a')
    def dy(self):
        self.driver.text(self.dy_py)
    #搜索框
    ssk_py = (By.XPATH,'//*[@id="wd1"]')
    # ssk1_py = (By.CSS_SELECTOR,'.//input[@search_ipt search_inp_border j_search_input tb_header_search_input]')
    def ssk(self):
        self.driver.click(self.ssk)
    #输入内容
    srnr_py = (By.XPATH,'/html/body/div[4]/div/div[1]/div[1]/div/div/div[2]/div/div[1]/form/input[1]')
    srnr1_py = (By.XPATH,'.//[@//*[@id="wd1"]]')
    def srnr(self):
        self.driver.send_keys(self.srnr_py)
    #点击进入贴吧
    jrtb_py = (By.XPATH,'//*[@id="tb_header_search_form"]/span[1]/a')
    # jrtb_pu1 = (By.TAG_NAME,'进入贴吧')
    def jrtb(self):
        self.driver.click(self.jrtb_py)
    #断言2 王者荣耀吧
    dy2_py = (By.XPATH,'//*[@id="pagelet_frs-header/pagelet/head"]/div/div[3]/div[2]/div[2]/div[2]/a')
    def dy2(self):
        self.driver.text(self.dy2_py)


    def test_baidutieba_01(self):
        self.get_url('https://tieba.baidu.com/')
        #强制等待
        sleep(3)
        self.login()
        self.djdl()
        self.srzh()
        self.srmm()
        self.djdl()
        sleep(3)
        self.dy()
        self.ssk()
        sleep(3)
        self.srnr()
        self.jrtb()
        sleep(3)
        self.dy2()


